|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectfurny.furndb.FurnDBManager
public final class FurnDBManager
Class that manages furniture database accesses.
This class is a SINGLETON.
| Field Summary | |
|---|---|
private com.jme3.asset.AssetManager |
assetManager
|
private javax.persistence.EntityManagerFactory |
entityManagerFactory
|
private java.util.concurrent.ExecutorService |
executor
|
private java.util.List<FurnitureUpdateListener> |
furnitureListeners
|
private static FurnDBManager |
INSTANCE
|
private static java.util.logging.Logger |
LOGGER
|
private static java.lang.String |
PARAMETERS
|
private java.util.List<TagUpdateListener> |
tagListeners
|
private java.util.List<java.lang.Long> |
updateIds
|
| Constructor Summary | |
|---|---|
private |
FurnDBManager()
Private constructor for single instance. |
| Method Summary | |
|---|---|
void |
addFurnitureTags(Furniture furniture,
java.util.Set<Tag> newTags)
Adds a new set of tags to an existing furniture. |
void |
addFurnitureUpdateListener(FurnitureUpdateListener listener)
Adds a FurnitureUpdateListener that will be notified about changes. |
void |
addTagUpdateListener(TagUpdateListener listener)
Adds a TagUpdateListener that will be notified about changes. |
private boolean |
convertTexturesToDB(javax.persistence.EntityManager entityManager,
Furniture f,
java.io.File path)
Helper method that creates byte arrays from textures to save them in the database. |
private javax.persistence.EntityManager |
createEntityManager()
Creates an EntityManager to start a database transaction. |
void |
deleteFurniture(java.lang.Long id)
Deletes a furniture from the database. |
void |
deleteTag(Tag tag)
Deletes a tag from the database. |
void |
exit()
Lets the manager exit and clean up its resources. |
private void |
fireFurnitureDeleted(java.lang.Long id)
Informs the listeners about an tag update. |
private void |
fireFurnitureUpdate(java.lang.Long id,
Furniture furniture)
Informs the listeners about an furniture update. |
com.jme3.asset.AssetManager |
getAssetManager()
Getter for the asset manager. |
Furniture |
getFurniture(java.lang.Long id)
Gets a furniture by id. |
java.util.List<java.lang.Long> |
getFurnitureIds()
Requests all furniture ids from the database. |
private java.util.List<java.lang.Long> |
getFurnitureIdsByString(SearchType searchType,
java.lang.String text,
boolean equals)
Finds furnitures by the given string and the type of the search to be performed. |
java.util.List<Furniture> |
getFurnitures()
Requests all furnitures from the database. |
static FurnDBManager |
getInstance()
Getter for the single instance. |
private java.util.List<Tag> |
getTags(TagType type)
Gets all tags of the given type. |
TextureData |
getTextureData(java.lang.String key)
Loads texture data for a model from the database. |
void |
removeTagUpdateListener(TagUpdateListener listener)
Removes a TagUpdateListener, so it will not be notified anymore. |
void |
saveFurniture(Furniture furniture,
boolean merge)
Saves a furniture to the database. |
void |
saveFurniture(Furniture furniture,
boolean merge,
java.io.File path)
Saves a furniture to the database. |
void |
saveTag(Tag tag)
Saves a new tag. |
void |
setCustomFilename(java.lang.String filename)
Sets a custom file name for the database. |
void |
setFurnitureTags(Furniture furniture,
java.util.Set<Tag> tags)
Sets a new set of tags for the existing furniture. |
void |
updateFurniture(java.lang.Long id)
Non-blocking method to get a furniture by id. |
void |
updateFurnitureIds()
Non-blocking method to get the furniture ids. |
void |
updateIdsByTagName(SearchType searchType,
java.lang.String text,
boolean equals)
Non-blocking method to get find furnitures by a string. |
void |
updateTags(TagType type)
Non-blocking method to get tags by their type. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final java.util.logging.Logger LOGGER
private static final FurnDBManager INSTANCE
private static final java.lang.String PARAMETERS
private javax.persistence.EntityManagerFactory entityManagerFactory
private final com.jme3.asset.AssetManager assetManager
private final java.util.List<FurnitureUpdateListener> furnitureListeners
private final java.util.List<TagUpdateListener> tagListeners
private final java.util.concurrent.ExecutorService executor
private final java.util.List<java.lang.Long> updateIds
| Constructor Detail |
|---|
private FurnDBManager()
| Method Detail |
|---|
public static FurnDBManager getInstance()
public void setCustomFilename(java.lang.String filename)
filename - Furniture database file name.public com.jme3.asset.AssetManager getAssetManager()
private javax.persistence.EntityManager createEntityManager()
EntityManager to start a database transaction.
public void saveFurniture(Furniture furniture,
boolean merge)
true if the
furniture already exists and needs only an update, otherwise it will be
created.
furniture - Furniture to savemerge - Merge (update) or create (insert)
public void saveFurniture(Furniture furniture,
boolean merge,
java.io.File path)
true if the
furniture already exists and needs only an update, otherwise it will be
created.
furniture - Furniture to savemerge - Merge (update) or create (insert)path - The path where this model has been loaded.
private boolean convertTexturesToDB(javax.persistence.EntityManager entityManager,
Furniture f,
java.io.File path)
throws java.io.IOException
entityManager - The open EntityManager.f - The furniture that contains the textures.path - The path where the textures are.
true if textures were converted and the furniture
needs to be re-saved.
java.io.IOException - if byte array conversion failspublic void saveTag(Tag tag)
tag - The tag to save.public void deleteFurniture(java.lang.Long id)
id - Id of the furniture that should be deletedpublic void deleteTag(Tag tag)
tag - Tag to delete.public java.util.List<java.lang.Long> getFurnitureIds()
public Furniture getFurniture(java.lang.Long id)
id - Id of the furniture to get.
public TextureData getTextureData(java.lang.String key)
key - The key of the texture.
public java.util.List<Furniture> getFurnitures()
private java.util.List<Tag> getTags(TagType type)
type - Type to find.
public void addFurnitureTags(Furniture furniture,
java.util.Set<Tag> newTags)
furniture - The furniture.newTags - The set of tags to add.
public void setFurnitureTags(Furniture furniture,
java.util.Set<Tag> tags)
furniture - The furniture.tags - The set of tags to set.
private java.util.List<java.lang.Long> getFurnitureIdsByString(SearchType searchType,
java.lang.String text,
boolean equals)
searchType - Type of search.text - String to search for.equals - If true the String must equal, otherwise it must be
contained.
public void updateFurnitureIds()
FurnitureUpdateListener. The listener will be notified
about the ids.
getFurnitureIds()public void updateTags(TagType type)
TagUpdateListener. The listener will be notified about
the tags.
type - Type to find.getTags(TagType)public void updateFurniture(java.lang.Long id)
FurnitureUpdateListener. The listener will be notified
about the furniture.
id - Id of the furniture to get.getFurniture(Long)
public void updateIdsByTagName(SearchType searchType,
java.lang.String text,
boolean equals)
FurnitureUpdateListener. The listener will be
notified about the furnitures.
searchType - Type of search.text - String to search for.equals - If true the String must equal, otherwise it must be
contained.getFurniture(Long)public void addFurnitureUpdateListener(FurnitureUpdateListener listener)
FurnitureUpdateListener that will be notified about changes.
listener - Listener to add.public void addTagUpdateListener(TagUpdateListener listener)
TagUpdateListener that will be notified about changes.
listener - Listener to add.public void removeTagUpdateListener(TagUpdateListener listener)
TagUpdateListener, so it will not be notified anymore.
listener - Listener to remove.
private void fireFurnitureUpdate(java.lang.Long id,
Furniture furniture)
id - Changed idfurniture - Changed furnitureprivate void fireFurnitureDeleted(java.lang.Long id)
id - Changed idpublic void exit()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||